extern byte BitCount[512] ;
extern byte Tblfirst0_8[512] ;

//! a 9 bitfield to give position of candidate in a house and similar functions
class BF16 {
public:
	word f;
	// constructors
	BF16() {f = 0;	}               
	BF16(int x) {f = 0x1ff;	}               
	inline int On(int ch) const {	return ((f & (1 << ch)));	}		
	inline int Off(int ch) const {	return (!(f & (1 << ch)));	}	
	inline void Set(word ch) {f |= (1 << ch);	}	
	inline void Clear(word ch) {	f &= ~(1 << ch);	}
	inline BF16 operator &(BF16 & e) const {		BF16 w;		w.f = f & e.f;		return w;	}
	inline BF16 operator |(BF16 & e) {		BF16 w;		w.f = f | e.f;		return w;	}
	inline BF16 operator ^(BF16 & e) {		BF16 w;		w.f = f ^ e.f;		return w;	}
	inline BF16 operator -(BF16 & e) {		BF16 w;		w.f = f ^ (e.f & f);		return w;	}
	inline int  operator ==(BF16 & e) {		return(e.f == f);	}
	inline void operator &=(BF16 & e) {	f &= e.f;	}
	inline void operator |=(BF16 & e) {	f |= e.f;	}
	inline void operator ^=(BF16 & e) {	f ^= e.f;	}
	inline void operator -=(BF16 & e) {	f ^= (f & e.f);	}
	inline int  First0_8() {return Tblfirst0_8[f];	}
	inline word bitCount() {	return BitCount[f];	}
	word String(word * rr);
	char * StringOut(char * out);
	//{int n=0; for(int i=0;i<9;i++) if(On(i)) rr[n++]=i;	return n;	}

}; // BF16


struct BF16_6{ 
	BF16 b[6];
};


/* COMBINE is a small module giving combination
   for a given size   (maths C n;p )

   the goal is to have a simpler code, not to improve the performance

*/
typedef unsigned int UINT;
class COMBINE
{public:
 UINT inds[15],  // internal table size p
	  p,      // maxi 15
	  lim,    // set to p-1 final index at the end
	  n;      // numer of objects in the table
 word * entry,*output;
  void Sort(); // internal function formating the output

public: 
 void First(int ne,int pe,word * d, word * f ); // initial
 int Next(); // get next group of index
};


struct COMB9{// one combination C 9-n  (9 36 64 126 126 64 36  9 ) 
	 BF16 bm;
	 word t[5],nt;
};